// src/api/common/LogAndRes.js
import apiClient from "@/api/client"

export default {
    // 登录API
    login(credentials) {
        return apiClient.post('auth/login/', {
            email: credentials.email,
            password: credentials.password
        })
    },

    // 注册API
    register(userData) {
        return apiClient.post('auth/register/', {
            username: userData.username,
            email: userData.email,
            password: userData.password
        })
    },

    // 登出API
    logout() {
        return apiClient.post('auth/logout/')
    },

    // 获取用户信息API
    getUserInfo() {
        return apiClient.get('auth/user/')
    },
    // 保留原始日志API
    logApi(message = '') {
        return apiClient.post('common/log_api/', {
            msg: message
        })
    },
    // 保留原始Redis API
    redisApi() {
        return apiClient.get('common/redis_api/')
    },
    // 新增：发送验证码API
    sendCaptcha(email) {
        return apiClient.post('auth/send_captcha/', {
            email: email
        })
    },
    // 新增：验证验证码API
    verifyCaptcha(email, captcha) {
        return apiClient.post('auth/verify_captcha/', {
            email: email,
            captcha: captcha
        })
    },
    // 新增：重置密码API
    resetPassword(email, newPassword) {
        return apiClient.post('auth/reset_password/', {
            email: email,
            new_password: newPassword
        })
    }
}